<?php
declare(strict_types=1);
/**
 * Created by project.
 * User: huanzipap
 * Date: 2023/5/11
 * Time: 15:01
 */

namespace App\Model;

use Hyperf\Database\Model\Model;
use Hyperf\Database\Model\SoftDeletes;

class ActClockJoin extends Model
{
    use SoftDeletes;
    protected ?string $table='act_clock_join';
    public bool $timestamps = true;

    protected array $fillable = ['party_id','act_id','uid','point_id','title','media_list'];


    public function user(): \Hyperf\Database\Model\Relations\belongsTo
    {
        return $this->belongsTo(User::class, 'uid', 'id');
    }


    public function zan(): \Hyperf\Database\Model\Relations\HasMany
    {
        return $this->hasMany(ActClockJoinZan::class, 'join_id', 'id');
    }

    public function comment(): \Hyperf\Database\Model\Relations\HasMany
    {
        return $this->hasMany(ActClockJoinComment::class, 'join_id', 'id');
    }


    public function setMediaListAttribute($value): void
    {
        $this->attributes['media_list'] = implode(',', $value);
    }

    public function getMediaListAttribute($value): array
    {
        return $value != null ? explode(',', $value) : [];
    }



}